import { Order, OrderStatistics } from '../types/qqOrder'
import request, { QuickResponseData } from '../utils/request'

const Api = {
  statistics: '/api/qqOrder/getStatistics',
  pageList: '/api/qqOrder/getPageList',
  add: '/api/qqOrder/add',
  update: '/api/qqOrder/update',
  delete: '/api/qqOrder/delete',
  batchDelete: '/api/qqOrder/batchDelete',
  excute: '/api/qqOrder/excute',
  batchExcute: '/api/qqOrder/batchExcute',
}
export const getOrderStatistics = (): Promise<
  QuickResponseData<OrderStatistics>
> => {
  return request<QuickResponseData<OrderStatistics>>({
    url: Api.statistics,
    method: 'GET',
  })
}
export const getOrderPageList = (
  params: object
): Promise<QuickResponseData<Array<Order>>> => {
  return request<QuickResponseData<Array<Order>>>({
    url: Api.pageList,
    method: 'GET',
    params,
  })
}
export const addOrder = (data: Order) => {
  return request({
    url: Api.add,
    method: 'POST',
    data,
  })
}
export const updateOrder = (data: Order) => {
  return request({
    url: Api.update,
    method: 'POST',
    data,
  })
}
export const deleteOrder = (id: string) => {
  return request({
    url: Api.delete,
    method: 'POST',
    data: {
      id,
    },
  })
}
export const batchDeleteOrder = (ids: string) => {
  return request({
    url: Api.batchDelete,
    method: 'POST',
    data: {
      ids,
    },
  })
}
export const excuteOrder = (id: string) => {
  return request({
    url: Api.excute,
    method: 'POST',
    data: {
      id,
    },
  })
}
export const batchExcuteOrder = (ids: string) => {
  return request({
    url: Api.batchExcute,
    method: 'POST',
    data: {
      ids,
    },
  })
}
